package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {

    void insert(Orders orders);

    void update(Orders orders);
    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String outTradeNo, Long userId);

    Page<Orders> Page(OrdersPageQueryDTO pageQueryDTO);
@Select("select * from orders where id=#{id}")
Orders selectById(Long id);

            @Select("select COUNT(id) from orders where status=#{status}")
            Integer select(Integer status);
@Select("select * from orders where status=#{status} and order_time < #{time} ")
    List<Long> selectTimeAndStatus(Integer status, LocalDateTime time);

    Double sumAmount(LocalDateTime timeBegin, LocalDateTime timeEnd, Integer status);

    Integer countUser(LocalDateTime timeBegin, LocalDateTime timeEnd);
@Select("select count(id) from orders where order_time>#{timeBegin} and order_time<#{timeEnd}")
    Integer selectOrder(LocalDateTime timeBegin, LocalDateTime timeEnd);
    @Select("select count(id) from orders where order_time>#{timeBegin} and order_time<#{timeEnd} and status=#{completed}")
    Integer selectcompleteOrder(LocalDateTime timeBegin, LocalDateTime timeEnd, Integer completed);

    List<GoodsSalesDTO> getsalestop10(LocalDateTime Begin, LocalDate End);


    Integer countByMap(Map map);

    Double sumByMap(Map map);

}
